package collection;

import java.util.ArrayList;
import java.util.Collection;


public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        point p = new point(1,2);
        c.add(p);//将p存入集合c
        System.out.println("p:"+p);//(1,2)
        System.out.println("c:"+c);//[(1,2)]

        p.setX(2);
        System.out.println("p:"+p);//(2,2)
        System.out.println("c:"+c);//[(2,2)]

        doSome(c,p);
        System.out.println("p:"+p);//(?,?)
        System.out.println("c:"+c);//[(?,?)]
    }

    public static void doSome(Collection c,point p){
        p.setX(3);
        p = new point(4,5);
        c = new ArrayList();
        c.add(p);
        p.setX(6);
    }
}
